﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href="/styles/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="/js/lib/angular.js"></script>
	    <script src="/js/lib/jquery.js"></script>
    <title>KAKA摄影--管理员登录</title>
</head>
<body ng-app="app" ng-controller="appController">
    <div class="container">
        <div class="jumbotron" style="margin-top:30px; padding:20px;">
            <div style="border-bottom:1px solid #ddd;"><h1 style="color:#068734;font-size:36px;font-weight:bold;"><span class="glyphicon glyphicon-lock" style="font-size:26px;"></span> 管理员登录</h1></div>
            <div style="margin-top:20px;">
                <form name="form1">
                    <div class="form-group">
                        <label for="exampleInputEmail1">用户名</label>
                        <input type="text" class="form-control" id="exampleInputEmail1" placeholder="必填" ng-model="loginForm.username" name="username" required ng-change="error=0">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">密码</label>
                        <input type="password" class="form-control" id="exampleInputPassword1" placeholder="必填" ng-model="loginForm.password" required ng-change="error=0">
                    </div>
                    <div class="alert alert-danger" role="alert" ng-show="error==1"><span class="glyphicon glyphicon-volume-up"></span>  糟糕，用户名和密码不正确，请输入正确的用户名和密码</div>
                    <div>
                        <button class="btn btn-success btn-lg" ng-click="login()" ng-disabled="form1.username.$invalid||form1.password.$invalid">登录</button>                        
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        
        var app = angular.module("app", []);
        app.controller('appController', function ($scope, $http) {
            $scope.error = 0;
            $scope.loginForm = {}; 
            $scope.login = function () {
                var Jsondata = $scope.loginForm;               
                $http({
                    url: '/admin/amdinLogin',
                    method: 'post',
                    data: Jsondata
                }).success(function (response) {
                    if(response.flag){
					window.location.href="/admin/index";					
					}else{
					  $scope.error = 1;
					}
                }).error(function () {
                    $scope.error = 1;
                })
            }
        });

    </script>
</body>
</html>
